Gdata1<-function(data, x0, h, noend)

        ## data   - Daten
        ## x0     - Evaluationspunkte
        ## h      - Vektor mit Bandweiten f�r jeden Regressor
        ## noend  - Anzahl endogener Variablen in Data (die ersten noend Variablen)

        {        

               
        # Ball erzeugen
        BALL.FILTER <- (abs(data[,noend+1]-x0[1])<h[1])
        for (i in (noend+2):length(data[1,]) ) {
            BALL.FILTER <- BALL.FILTER & (abs(data[,i]-x0[i-noend])<h[i-noend])
        }
        DIB<-matrix(  data[BALL.FILTER] ,ncol=length(data[1,]))  
        #print(  paste("Daten/DIB:", length(data[,1]), length(DIB[,1]) )  )
        
        if (length(DIB[,1])<50)
        
                        {
                            h<-1.5*h
                            BALL.FILTER <- (abs(data[,noend+1]-x0[1])<h[1])
                            for (i in (noend+2):length(data[1,]) ) 
                            {
                            BALL.FILTER <- BALL.FILTER & (abs(data[,i]-x0[i-noend])<h[i-noend])
                            }
                            DIB<-matrix(  data[BALL.FILTER] ,ncol=length(data[1,]))  
                            #print(  paste("Daten/DIB2:", length(data[,1]), length(DIB[,1]) )  )
                        }
          
        XXX <- 1
        for (i in (noend+1):length(data[1,]) ) 
            {
            XXX <- XXX * Kern( DIB[,i],x0[i-noend],h[i-noend] )
            }        
        XXX <- sqrt(XXX)
    
        # Regressoren
        
        X <-rep(1,length(DIB[,1]))*XXX
        
        for (i in (noend+1):length(data[1,]) ) {
            DD <- (DIB[,i]-x0[i-noend])*XXX
            X <- cbind(X, DD)
        }
        
        
        # Abh�ngige Variablen
        Y<-DIB[,1] * XXX
        #for (i in 2:noend) {
        #    DD<-DIB[,i] * XXX
        #    Y <- cbind(Y, DD)
        #}
        
        # Regression
        mdach<-qr.coef(qr(X),Y)
        mdach
} # Ende Funktion Gdata

Kern <- function(X,x0,h) {
    1/h*.75*(1-((X-x0)/h)^2)
}
